﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T08
{
    class Program
    {
        static void Main(string[] args)
        { 
            Account a1 = new Account();
            Console.WriteLine("用户名：{0} 计数：{1} PI{2}",a1.usernam,Account.total,Account.PI);
            ///a1.type="b" 错误 只读字段不能更改值
            Account a2 = new Account();
            a2.usernam = "张三";//实例字段可以更改
            Console.WriteLine("用户名：{0} 计数：{1} PI{2}", a2.usernam, Account.total,Account.PI);
            Console.ReadKey();
        }
    }
}
class Account
{
    public static int total;//静态字段，属于类的所有对象
    public string usernam;//实例字段，属于单个对象
    public readonly string type;//只读字段，在定义及构造函数初始化
    public const double PI = 3.14;//常量字段，实际为静态字段
    public Account()
    {
        total++;
        usernam = "用户";
        type = "a";

    }
}
